package pack3;

import pack3.utils.Heap;
import pack3.utils.Utils;

import java.util.Arrays;

public class HeapSort {

    public static void main(String[] args) {
        int []arr=new int[]{7,5,6,9,10,1,3,7,4,3,2};
        int[]arr2=new int[]{10,9,8,7,6,5,4,3,2,1};
        heapSort(arr);
        heapSort(arr2);
        System.out.println(Arrays.toString(arr));
        System.out.println(Arrays.toString(arr2));
    }


    public static void heapSort(int[]arr){
        //将数组创建成大根堆
        Heap.createHeap_1(arr);
        int end= arr.length-1;
        for (; end>=0; end--) {
            Utils.swap(arr, 0,end);
            Heap.jugeDown(arr,0,end);
        }
    }

}
